package com.suixun.test;


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import cn.jiguang.common.ClientConfig;
import cn.jiguang.common.resp.APIConnectionException;
import cn.jiguang.common.resp.APIRequestException;
import cn.jpush.api.JPushClient;
import cn.jpush.api.push.PushResult;
import cn.jpush.api.push.model.PushPayload;

public class JpushDemo {
		protected static Log logger = LogFactory.getLog(JpushDemo.class);
		public final static String MASTER_SECRET="3970685179fcdfdf97665713";
		public final static String APP_KEY="902da7f207b58d9834b97374";
		public final static String ALERT="消息推送成功！";
		public static void main(String[] args) {
		JPushClient jpushClient = new JPushClient(MASTER_SECRET, APP_KEY, null, ClientConfig.getInstance());
		 PushPayload payload = buildPushObject_all_all_alert();
		 try {
		        PushResult result = jpushClient.sendPush(payload);
			 	
		        logger.info("Got result - " + result);

		    } catch (APIConnectionException e) {
		        // Connection error, should retry later
		    	logger.error("Connection error, should retry later", e);

		    } catch (APIRequestException e) {
		        // Should review the error, and fix the request
		    	logger.error("Should review the error, and fix the request", e);
		        logger.info("HTTP Status: " + e.getStatus());
		        logger.info("Error Code: " + e.getErrorCode());
		        logger.info("Error Message: " + e.getErrorMessage());
		    }
			//testSendWithSMS();
			
	}
	/**
	 * 
	 * <p>Title: buildPushObject_all_all_alert</p>
	 * <p> 功能描述:推送所有平台，所有设备，内容为ALERT的通知 </p>
	 * @return
	 */
	public static PushPayload buildPushObject_all_all_alert() {
        return PushPayload.alertAll(ALERT);
    }
	
	 
}
